package MailBox;

import java.util.Random;

public class Penerima implements Runnable {
	private KotakSurat kotakSurat;
	public Penerima(KotakSurat kotakSurat){
		this.kotakSurat = kotakSurat;
	}
	public void ambil() throws InterruptedException{
		kotakSurat.ambil();
	}
	public void run(){
		try{
			for(int i=0; i<5; i++){
				ambil();
				System.out.println("Jumlah surat : " +kotakSurat.jumlah());
				Thread.sleep(new Random().nextInt(2000));
			}
		}catch (Exception err){
			err.printStackTrace();
		}
	}
}
